package sample3.provider.ddl;

public class SqliteIndexBuilder extends AbsDdlBuilder {
	private String mTargetTable;
	private String mTargetColumn;

	public SqliteIndexBuilder(String targetTable) {
		super(targetTable + "_index");
		mTargetTable = targetTable;
	}

	public void setTargetColumn(String targetColumn) {
		mTargetColumn = targetColumn;
	}

	@Override
	String toDropSql() {
		return "DROP INDEX IF EXISTS " + getName();
	}

	@Override
	String toCreateSql() {
		StringBuilder sql = new StringBuilder();
		sql.append("CREATE INDEX IF NOT EXISTS ").append(getName());
		sql.append("\n ON ").append(mTargetTable).append('(').append(mTargetColumn).append(')');
		return sql.toString();
	}
}
